package com.hzcx.app.simplechat.ui.chat.dialog;

import android.content.Context;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.base.BaseDialog;
import com.hzcx.app.simplechat.ui.friend.bean.FriendBean;
import com.hzcx.app.simplechat.util.empty.EmptyUtils;
import com.hzcx.app.simplechat.util.glide.GlideUtils;
import com.hzcx.app.simplechat.view.imageview.RoundImageView;

import butterknife.BindView;

/**
 * 分享名片弹窗
 */
public class ChatCollectDialog extends BaseDialog {
    @BindView(R.id.iv_head)
    RoundImageView ivHead;
    @BindView(R.id.tv_nick_name)
    TextView tvNickName;
    @BindView(R.id.tv_content)
    TextView tvContent;
    @BindView(R.id.et_remark)
    EditText etRemark;
    @BindView(R.id.tv_cancel)
    TextView tvCancel;
    @BindView(R.id.tv_send)
    TextView tvSend;
    private String head;
    private String nickName;
    private String content;
    private String imgContent;

    private OnChatCollectListener listener;

    public ChatCollectDialog(@NonNull Context context, String head, String nickName, String content, String imgContent, OnChatCollectListener listener) {
        super(context);
        this.head = head;
        this.nickName = nickName;
        this.listener = listener;
        this.content = content;
        this.imgContent = imgContent;
    }

    @Override
    public int getLayout() {
        return R.layout.dialog_chat_collect;
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void initView() {

        GlideUtils.loadImg(context, head, ivHead);
        tvNickName.setText(nickName);
        if (EmptyUtils.isEmpty(imgContent)) {
            tvContent.setText("["+content+"]");
        } else {
            tvContent.setText("[图片]");
        }

        tvCancel.setOnClickListener(view -> dismiss());

        tvSend.setOnClickListener(view -> {
            if (listener != null) {
                listener.sendCollect(etRemark.getText().toString());
            }
            dismiss();
        });
    }

    @Override
    public void initData() {

    }

    public interface OnChatCollectListener {
        void sendCollect(String remark);
    }
}
